package com.ysd.lis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.*;
import com.ysd.lis.mapper.sys.*;
import com.ysd.lis.request.SysRoleDetailsParam;
import com.ysd.lis.service.SysRoleDetailsService;
import com.ysd.util.RedisUserManager;
import com.ysd.util.ToolsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * cold_chain.sys_module 服务实现类
 * </p>
 *
 * @author Bai
 * @since 2023-10-18
 */
@Service
public class SysRoleDetailsServiceImpl extends ServiceImpl<SysRoleDetailsMapper, SysRoleDetails> implements SysRoleDetailsService {

    @Autowired
    SysMenuMapper sysMenuMapper;
    @Autowired
    SysPointsMapper sysPointsMapper;
    @Autowired
    SysRoleDetailsMapper sysRoleDetailsMapper;
    @Autowired
    SysRoleMenuMapper sysRoleMenuMapper;
    @Autowired
    SysRolePointsMapper sysRolePointsMapper;

    @Override
    public Result getRoleDetailsByRoleId(SysRoleDetailsParam sysRoleDetailsParam) {
        if(ToolsUtils.isEmpty(sysRoleDetailsParam)){
           return Result.fail("获取角色Id异常");
        }
        if(ToolsUtils.isEmpty(sysRoleDetailsParam.getRoleId())){
            return Result.fail("获取角色Id异常");
        }
            String roleId = sysRoleDetailsParam.getRoleId();

            LambdaQueryWrapper<SysRoleDetails> queryWrapper = new LambdaQueryWrapper<>();
            SysUser sysUser = RedisUserManager.getUser();
            queryWrapper.eq(SysRoleDetails::getOrgId, sysUser.getOrgId()).eq(SysRoleDetails::getDelFlag, "0").eq(SysRoleDetails::getRoleId,roleId);
            List<SysRoleDetails> list = sysRoleDetailsMapper.selectList(queryWrapper);
            return Result.succ(1, "获取信息成功", list);
        }


}
